package com.czh.controller;

import com.czh.domain.ResponseResult;
import com.czh.domain.dto.AddUserDto;
import com.czh.domain.dto.ChangeUserStatusDto;
import com.czh.domain.dto.QueryUserDto;
import com.czh.domain.dto.UpdateUserDto;
import com.czh.domain.vo.UserPageVo;
import com.czh.domain.vo.UserUpOldInfoVo;
import com.czh.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
 * 用户管理控制器
 */
@RestController
@RequestMapping("system/user")
public class UserManageController {
    @Autowired
    private UserService userService;
    @GetMapping("/list")
    public ResponseResult<UserPageVo> userPage(Integer pageNum, Integer pageSize, QueryUserDto queryUserDto){
        return userService.userPage(pageNum,pageSize,queryUserDto);
    }
    @PostMapping
    public ResponseResult<Object> addUser(@RequestBody AddUserDto addUserDto){
        return userService.addUser(addUserDto);
    }
    @DeleteMapping("/{id}")
    public ResponseResult<Object> deleteUser(@PathVariable("id") Long id){
        return userService.deleteUser(id);
    }
    //修改用户时填充信息
    @GetMapping("/{id}")
    public ResponseResult<UserUpOldInfoVo> userOldInfo(@PathVariable("id") Long id){
        return userService.userOldInfo(id);
    }
    @PutMapping
    public ResponseResult<Object> updateUser(@RequestBody UpdateUserDto updateUserDto){
        return userService.updateUser(updateUserDto);
    }
    @PutMapping("/changeStatus")
    public ResponseResult<Object> changeStatus(@RequestBody ChangeUserStatusDto statusDto){
        return userService.changeStatus(statusDto);
    }
}
